<%@ include file="/taglibs.jsp" %>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<head>
		<title>北京邮电大学学生党员在线学习中心</title>

		<link href="${ctx}/css/pagination.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="${ctx }/ckeditor/ckeditor.js"></script>
		<script type="text/javascript" src="${ctx}/scripts/jquery-1.6.2.js"></script>
		<script type="text/javascript" src="${ctx}/scripts/jquery-datepicker.js"></script>
		<script type="text/javascript" src="${ctx}/scripts/jquery-ui-1.8.16.custom.min.js"></script>
		<script type="text/javascript">
		function showUpload(value){
			if(value == 1) document.getElementById("newsPic").style.display="inline";
			else document.getElementById("newsPic").style.display="none";
		}
		</script>
		<script type="text/javascript">
		 function new_topic(file)
	      {
			 try
			 { 
				 
			   var title = document.getElementById("title");
			   var editor_data = CKEDITOR.instances.content.getData();
			   var pic = document.getElementsByName("picTag");
			   var picPath = <%=request.getAttribute("currentNews.picPath")%>;
			   if(title.value.replace(/(^\s*)/g, "") == "")
			   {
			       alert("请输入标题!");
			       title.focus();
			       return false;
			   }
			   
			   if(editor_data==null || editor_data==""){
					alert("请输入发布的内容");
					CKEDITOR.instances.content.focus();
					return false;
				}
			   
			   var radioChoose;
			   
			   if(pic != null){
				   for(i=0;i<pic.length;i++){
					   
					   if(pic[i].checked){
						   radioChoose = pic[i].value;
					   }
				   }
			   }
			   
			   if(radioChoose==1 && !file && (picPath == null || picPath=="")){
				   
				   alert("必须上传图片文件");
				   
				   return false;
			   }
			   
			   }
			   catch(e)
			   {
			       alert(e);
			       return false;
			   }
	    }
    </script>
    
    
    
    <script type="text/javascript">
	$(function(){
		var newsCategory = '<%=request.getAttribute("tag") %>';
		
		//alert(newsCategory);
		
		var data = "";
		if(newsCategory==1){
			var data = "上级精神管理"; 
			$('#links').attr("href","${ctx}/Admin_PartyNewsAction_manageSpiritNews");
		}else if(newsCategory==2){
			var data = "学校要闻管理"; 
			$('#links').attr("href","${ctx}/Admin_PartyNewsAction_manageSchoolNews");
		}else if(newsCategory==3){
			var data = "院系风采管理";
			$('#links').attr("href","${ctx}/Admin_PartyNewsAction_manageCollegeNews");
		}
		// Change pageLabel
		$('#pageLabel').text(data);
	});
	
	</script>
	
</head>
<div id="nav_bar">
    <img id="nav_bar_left" src="../../../styles/nav_bar_left.png" alt=""/>
    <div id="welcome_label">欢迎您，&nbsp;<s:property value="#session.session_user.adminName" />!</div>
    <img id="nav_bar_seperator" src="../../../styles/nav_bar_seperator.png" alt=""/>
    <div id="nav_location">
        <img id="nav_bar_point" src="../../../styles/nav_bar_point.png" alt="" />
        <div id="nav_cur_location">当前位置：&nbsp;<a href="${ctx}/Admin_PartyNewsAction_managePartyNews">党建动态管理</a>&nbsp;&nbsp;>&nbsp;&nbsp;
         <a  id="links"  href="#" ><span id="pageLabel" style="color:black;"></span></a>&nbsp;&nbsp;>&nbsp;&nbsp;
         <s:if test="#request.tag==1">
         	修改上级精神
         </s:if><s:elseif test="#request.tag==2">
         	修改学校要闻
         </s:elseif><s:else>
         	修改院系风采
         </s:else>
        </div>
    </div>
    <img style="float:right; width:5px;" src="../../../styles/nav_bar_right.png" alt=""/>
    <a id="nav_logout" href="${ctx}/logoutAction_adminLogout">[安全退出]</a>
</div>

<div style="clear:both; height:20px;">&nbsp;</div>

<div style="margin-left:auto; margin-right:auto; width:96%;">
		<s:form  action="Admin_PartyNewsAction_saveModifyNews" method="post" theme="simple" enctype="multipart/form-data">
			<table>
			<tr>
				<td >
				<b>标&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;题：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b>
				</td>
 				<td >
 				<input type="text" name="title" id="title"  maxlength="60" style="width:99%" value="<s:property value="currentNews.title"/>"/>
				</td>
			</tr>
			<tr>
				<td>
				<b>内&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;容：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b>
				</td>
 				<td >
 						<ckfinder:setupCKEditor editor="content" basePath="ckfinder"/>
			            <ckeditor:editor basePath="ckeditor/" editor="content" value="${currentNews.content}" /> 
				</td>
			</tr>
		</table>
		
			
			<div align="left">
			<table  >
			<tr>
				<td >
				<b>图片新闻：&nbsp;&nbsp;</b>
				</td>
				<td >
				<s:radio list="#{1:'是',0:'否'}" theme="simple" listKey="key" listValue="value" name="picTag" value="#request.currentNews.picTag" onclick="showUpload(this.value);"></s:radio>
				</td>
			</tr>
			</table>
			</div>
			
			<div id="newsPic" style="display:none;" align="left">
				<table >
				
				<tr>
					<td >
						<b>上传图片：</b>
					</td>
					<td>
					<input type="file"  name="newsPic" id="newsPic" />
					</td>
				</tr>
				<s:if test="currentNews.picPath != null && currentNews.picPath != ''">
				<tr>
					<td>
				 	 <b>当前图片：</b>
					</td>
					<td>
						<img style="max-width:300px; max-height:300px; border:solid 1px #ffbb66; padding:5px; margin-bottom:5px;" src="<s:property value="currentNews.picPath"/>"/>
					</td>
				</tr>
				</s:if>
				</table>
				
				<script type="text/javascript">
					var picTag = <%=request.getAttribute("currentNews.picTag")%>
					if(picTag == 1) document.getElementById("newsPic").style.display="inline";
					else document.getElementById("newsPic").style.display="none";
				</script>
		  </div>
			<br>
			<input type="hidden" value="<s:property value="currentNews.id"/>" name="id">
			<input type="hidden" value="<s:property value="#request.modifyNewsPageNow"/>" name="modifyNewsPageNow"/>
			<div align="center">
			<input id="posttopic" name="posttopic" type="submit"  onclick="return new_topic(this.form.newsPic.value);"   value="保存" class="input-button" />&nbsp;&nbsp;&nbsp;&nbsp;
			<input id="history" name="history" type="button" class="input-button" value="返回"  onclick="window.location.href='javascript:history.go(-1);'"/>
			</div>
			</s:form>
</div>

